/*
 +----------------------------------------------------------------------
 + Title        : 用户接口
 + Author       : huwl
 + Version      : 1.0.0
 + Initial-Time : 2023-08-10
 + Last-time    : 这个文件最后修改的时间 + 修改人的名称
 + Desc         : 用户接口
 +----------------------------------------------------------------------
*/

import request from '@/utils/httpRequest'

/**
 * 密码登录
 * @param object data-------------------------------------------请求参数
 * @param string username --------------------------------------必传,用户名
 * @param string password --------------------------------------必传,密码
 * return json
 * author huwl
 */
export const reqLoginAPI = (data) => {
    return request({
        method: 'POST',
        url: 'user/login',
        data
    })
}

/**
 * 短信登录
 * @param object data-------------------------------------------请求参数
 * @param string mobile ----------------------------------------必传,手机号
 * @param string code ------------------------------------------必传,验证码
 * return json
 * author huwl
 */
export const reqMobileLoginAPI = (data) => {
    return request({
        method: 'POST',
        url: 'user/mobileLogin',
        data
    })
}

/**
 * 注册
 * 
 * 参数data包含以下数据
 *  @param string username --------------------------------------必传,用户名
 *  @param string password --------------------------------------必传,密码
 *  @param string repassword ------------------------------------必传,重复密码
 *  @param string mobile ----------------------------------------必传,手机号
 * return Json
 * author huwl
 */
export const reqRegisterAPI = (data) => {
    return request(
        {
            method: 'POST',
            url: 'user/register',
            data
        }
    )
}

/**
 * 编辑用户
 * 
 * 参数data包含以下数据
 *  @param string name ------------------------------------------非必传,姓名
 *  @param string nick ------------------------------------------非必传,昵称
 *  @param string avatar_url ------------------------------------非必传,头像
 *  @param string gender ----------------------------------------非必传,性别
 * return Json
 * author huwl
 */
export const reqEditUserAPI = (data) => {
    return request(
        {
            method: 'POST',
            url: 'user/edit',
            data
        }
    )
}

/**
 * 修改手机号
 * 
 * @param string mobile ----------------------------------------必传,手机号
 * return Json
 * author huwl
 */
export const reqEditMobileAPI = (mobile) => {
    return request(
        {
            method: 'POST',
            url: 'user/editMobile',
            data: {mobile}
        }
    )
}

/**
 * 修改邮箱
 * 
 * @param string email -----------------------------------------必传,邮箱
 * return Json
 * author huwl
 */
export const reqEditEmailAPI = (email) => {
    return request(
        {
            method: 'POST',
            url: 'user/editEmail',
            data: {email}
        }
    )
}

/**
 * 修改密码
 * 
 * 参数data包含以下数据
 *  @param string raw_password ----------------------------------必传,原密码
 *  @param string new_password ----------------------------------必传,新密码
 *  @param string repassword ------------------------------------必传,确认密码
 * return Json
 * author huwl
 */
export const reqChangePasswordAPI = (data) => {
    return request(
        {
            method: 'POST',
            url: 'user/changePassword',
            data
        }
    )
}

/**
 * 登录发送验证码
 * 
 * @param string mobile ----------------------------------------必传,手机号
 * return Json
 * author huwl
 */
export const reqLoginSendCodeAPI = (mobile) => {
    return request(
        {
            method: 'POST',
            url: 'user/loginSendCode',
            data: {mobile}
        }
    )
}

/**
 * 使用微信绑定的手机号登录
 * 
 * @param string code ------------------------------------------必传,动态令牌
 * return Json
 * author huwl
 */
export const reqWxMobileLoginAPI = (code) => {
    return request(
        {
            method: 'POST',
            url: 'user/wxMobileLogin',
            data: {code}
        }
    )
}

/**
 * 手机找回密码发送验证码
 * 
 * @param string mobile ----------------------------------------必传,手机号
 * return Json
 * author huwl
 */
export const reqMobileForgotSendCodeAPI = (mobile) => {
    return request(
        {
            method: 'POST',
            url: 'user/mobileForgotPasswordSendCode',
            data: {mobile}
        }
    )
}

/**
 * 邮箱找回密码发送验证码
 * 
 * @param string email ----------------------------------------必传,邮箱
 * return Json
 * author huwl
 */
export const reqEmailForgotSendCodeAPI = (email) => {
    return request(
        {
            method: 'POST',
            url: 'user/emailForgotPasswordSendCode',
            data: {email}
        }
    )
}

/**
 * 手机找回密码
 * 
 * 参数data包含以下数据
 *  @param string mobile ----------------------------------------必传,手机号
 *  @param string code ------------------------------------------必传,验证码
 *  @param string new_password ----------------------------------必传,新密码
 *  @param string repassword ------------------------------------必传,确认密码
 * return Json
 * author huwl
 */
export const reqMobileForgotPasswordAPI = (data) => {
    return request(
        {
            method: 'POST',
            url: 'user/mobileForgotPassword',
            data
        }
    )
}

/**
 * 邮箱找回密码
 * 
 * 参数data包含以下数据
 *  @param string email -----------------------------------------必传,邮箱
 *  @param string code ------------------------------------------必传,验证码
 *  @param string new_password ----------------------------------必传,新密码
 *  @param string repassword ------------------------------------必传,确认密码
 * return Json
 * author huwl
 */
export const reqEmailForgotPasswordAPI = (data) => {
    return request(
        {
            method: 'POST',
            url: 'user/emailForgotPassword',
            data
        }
    )
}

/**
 * 刷新token
 * 
 * @param string refresh_token ---------------------------------必传,刷新token
 * return Json
 * author huwl
 */
export const reqRefreshTokenAPI = (refresh_token) => {
    return request(
        {
            method: 'POST',
            url: 'user/refreshToken',
            data: {refresh_token}
        }
    )
}